package com.my.screenadapter.sql;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.my.screenadapter.Base.BaseActivity;
import com.my.screenadapter.MyApplication;
import com.my.screenadapter.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SqliteUpdateActivity extends BaseActivity {

    @BindView(R.id.btn_createTable)
    Button btnCreateTable;
    @BindView(R.id.btn_ins)
    Button btnIns;
    @BindView(R.id.btn_select)
    Button btnSelect;
    @BindView(R.id.et)
    EditText et;
    @BindView(R.id.btn_execute_sql)
    Button btnExecuteSql;
    private DBUtil util;

    @Override
    protected void init() {
        util = new DBUtil(MyApplication.getContext(), DBUtil.DATABASE_NAME, null, DBUtil.DATABASE_VERSION);

    }

    @Override
    protected int initLayoutId() {
        return R.layout.activity_sqlite_update;
    }

    @OnClick({R.id.btn_createTable,R.id.btn_ins,R.id.btn_select,R.id.btn_execute_sql})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.btn_ins:
                util.insertPlan(1,"张三","是个可爱的人");
                break;
            case R.id.btn_select:
                util.selectCompany();
                break;
            case R.id.btn_execute_sql:
                if (!TextUtils.isEmpty(et.getText().toString())){
                    util.execute(et.getText().toString());
                }
                break;

        }
    }


}
